/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DTO;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.SAXException;

/**
 *
 * @author ThanhTai
 */
public class ProjectsUpdateSAXProcessor implements Serializable {

    public ProjectsUpdateSAXProcessor() {
    }

    public void update(String xmlPath, String xmlFile) {
        {
            BufferedWriter out = null;
            try {
                String result = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + xmlFile;
                ProjectsUpdateSAXParser obj = new ProjectsUpdateSAXParser();
                SAXParserFactory spf = SAXParserFactory.newInstance();
                SAXParser parser = spf.newSAXParser();
                File file = new File(xmlPath);
                out = new BufferedWriter(new FileWriter(file));
                out.write(result);
                out.close();
            } catch (IOException ex) {
                Logger.getLogger(ProjectsUpdateSAXProcessor.class.getName()).log(Level.SEVERE, null, ex);
            } catch (ParserConfigurationException ex) {
                Logger.getLogger(ProjectsUpdateSAXProcessor.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SAXException ex) {
                Logger.getLogger(ProjectsUpdateSAXProcessor.class.getName()).log(Level.SEVERE, null, ex);
            } finally {
                try {
                    out.close();
                } catch (IOException ex) {
                    Logger.getLogger(ProjectsUpdateSAXProcessor.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    }
}
